home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 026a / brow1_01.zip / BROWDEMO.PRG < prev    next >
Text File  |  1990-08-16  |  7KB  |  229 lines

  1. *:*********************************************************************
  2. *:
  3. *:        Program: BROWDEMO.PRG
  4. *:
  5. *:         System: BROWSE / POPUP Demo
  6. *:         Author: Ron Blechman
  7. *:      Copyright (c) 1990, Sound Processes, Inc.
  8. *:  Last modified: 08/16/90      5:03
  9. *:
  10. *:  Procs & Fncts: KEYHAND
  11. *:               : KEYDISP
  12. *:
  13. *:          Calls: KEYHAND        (procedure in BROWDEMO.PRG)
  14. *:
  15. *:           Uses: (DBFILE).DBF   
  16. *:
  17. *:   Binary Files: KEYBD.BIN
  18. *:
  19. *:      Documented 08/16/90 at 05:06                SNAP!  version 4.02d
  20. *:*********************************************************************
  21.  
  22.  
  23. **************************************************************************
  24. *  DISCLAIMER: This program is provided as is for demonstration
  25. *              purposes only. Its sole intent is for enlightenment
  26. *              within the dBASE development community.
  27. *              Feel free to incorporate these concepts within
  28. *              your own applications as you see fit.
  29. *              - Ron Blechman
  30. ***************************************************************************
  31.  
  32. SET TALK OFF
  33. SET ESCAPE OFF
  34. SET SCOREBOARD OFF
  35. SET STATUS OFF
  36. CLOSE ALL
  37. db1_0 =  ("1.0" $ VERSION())  && Set to True if dBASE IV 1.0
  38.  
  39. LOAD keybd
  40.  
  41. CLEAR
  42.  
  43. @ 20, 30 SAY "BROWDEMO - Version 1.01"
  44. @ 6, 8 TO 18,72
  45. @ 8, 16 SAY "The following is an demonstration of how BROWSE"
  46. @ 9, 16 SAY "can be used as an alternative to POPUPs."
  47. @ 11, 16 SAY "By: Ron Blechman"
  48. @ 12, 20 SAY "Sound Processes, Inc."
  49. @ 13, 20 SAY "6 Laurel Drive"
  50. @ 14, 20 SAY "Fair Haven, NJ 07704"
  51. @ 16, 16 SAY "Press any key to continue...."
  52. foo = INKEY(0)
  53.  
  54. demoit = .T.
  55. DO WHILE demoit
  56.    
  57.    CLEAR
  58.    
  59.    **************************************************************
  60.    * Browdemo.dbf has been indexed with 3 examples
  61.    * ORDER Fullname = UPPER(Lastname - "," - Firstname)
  62.    * ORDER Fullname2 = UPPER(Lastname - Firstname)
  63.    * ORDER Fullname3 = UPPER(Lastname + Firstname)
  64.    *
  65.    * Note that Fullname2 and Fullname3 have problems when
  66.    * searching/ording similar last and firstnames.
  67.    * (e.g. Try searching for the string "you")
  68.    **************************************************************
  69.    dbfile  = "BROWDEMO"
  70.    dborder = "FULLNAME"
  71.    USE (dbfile)
  72.    SET ORDER TO (dborder)
  73.    @ 2, 4 SAY "Database File: "+dbfile
  74.    @ 3, 12 SAY "Order: "+dborder
  75.    matchstr = ""
  76.    uselect = .F.
  77.    
  78.    SET EXACT OFF
  79.    CLEAR TYPEAHEAD
  80.    GOTO TOP
  81.    
  82.    SET FIELDS TO
  83.    
  84.    @ 21,10 SAY "Enter Search String, or Press ENTER to Select, or ESC to CANCEL."
  85.    @ 22,10 SAY "You may also use the cursor keys for positioning."
  86.    @ 18,24 SAY "Search String:"
  87.    DEFINE WINDOW browwin FROM 02,40 TO 15,65
  88.    DEFINE WINDOW inwin FROM 17,40 TO 19,65
  89.    ACTIVATE WINDOW inwin
  90.    
  91.    matchstr = ""
  92.    uselect = .F.
  93.    ON KEY DO keyhand
  94.    BROWSE NOEDIT NOAPPEND NOMENU WINDOW browwin FIELDS ;
  95.       name = IIF(""=TRIM(firstname), lastname,TRIM(lastname)+", "+firstname)
  96.    ON KEY
  97.    
  98.    RELEASE WINDOW browwin
  99.    RELEASE WINDOW inwin
  100.    
  101.    CLEAR
  102.    @ 8,8 TO 12,78
  103.    IF uselect
  104.       @ 10,16 SAY "Name Selected:"
  105.       @ 10,31 SAY IIF(""=TRIM(firstname), lastname, TRIM(lastname)+", "+firstname)
  106.    ELSE
  107.       @ 10,30 SAY "Canceled Selection"
  108.    ENDIF
  109.    
  110.    demoit = .F.
  111.    @ 14,20 SAY "Do you want to try it again? " GET demoit PICTURE "Y"
  112.    READ
  113. ENDDO
  114.  
  115. RELEASE MODULE keybd
  116.  
  117. CLOSE ALL
  118. CLEAR
  119. RETURN
  120.  
  121. *!*********************************************************************
  122. *!
  123. *!      Procedure: KEYHAND
  124. *!
  125. *!      Called by: BROWDEMO.PRG                  
  126. *!               : KEYHAND        (procedure in BROWDEMO.PRG)
  127. *!
  128. *!          Calls: KEYHAND        (procedure in BROWDEMO.PRG)
  129. *!               : KEYDISP        (procedure in BROWDEMO.PRG)
  130. *!
  131. *!   Binary Files: KEYBD.BIN
  132. *!
  133. *!*********************************************************************
  134. PROCEDURE keyhand
  135. ON KEY
  136. trapkey = 26            && Set to numeric value of HOME, the "trap key"
  137. userpress = INKEY(0)
  138.  
  139. DO CASE
  140. CASE userpress = 27     && Esc will exit
  141.    ** You MUST do two escapes for this to work
  142.    CALL keybd WITH CHR(27) + CHR(27)
  143.    uselect = .F.
  144.    GOTO TOP
  145. CASE userpress = 13    &&  Enter will select
  146.    CALL keybd WITH CHR(27)
  147.    uselect = .T.
  148. CASE userpress = trapkey     && Home
  149.    *** Home is used as a special key - used with keyboard stuffing
  150.    CLEAR TYPEAHEAD
  151.    ON KEY DO keyhand
  152. CASE userpress = 3 ;
  153.       .OR. userpress = 4 ;
  154.       .OR. userpress = 5 ;
  155.       .OR. userpress = 18 ;
  156.       .OR. userpress = 24 ;
  157.       .OR. userpress = 25 ;
  158.       .OR. userpress = 30 ;
  159.       .OR. userpress = 31
  160.    ** Cursor movement keys
  161.    IF "" # matchstr
  162.       matchstr = ""
  163.       DO keydisp WITH ""
  164.    ENDIF
  165.    IF userpress = 25
  166.       ** Ctrl-Y clears input string but preserves current record position
  167.       ON KEY DO keyhand
  168.    ELSE
  169.       ** Stuff the keyboard buffer with cursor key to move record position
  170.       CALL keybd WITH CHR(userpress)+CHR(trapkey)
  171.       ON KEY LABEL home DO keyhand
  172.    ENDIF
  173. OTHERWISE
  174.    ** Search for input string
  175.    recnum = RECNO()
  176.    DO CASE
  177.    CASE userpress = 19 ;
  178.          .OR. userpress = 127
  179.       ** Backspace or Left arrow erases one character
  180.       matchstr = SUBSTR(matchstr,1,LEN(matchstr)-1)
  181.       newstr = matchstr
  182.    OTHERWISE
  183.       newstr = matchstr + CHR(userpress)
  184.    ENDCASE
  185.    
  186.    SEEK UPPER(newstr)
  187.    
  188.    IF FOUND()
  189.       matchstr = newstr
  190.       DO keydisp WITH matchstr
  191.       ************************************************************
  192.       * In dBASE IV 1.0, Browse will not automatically reposition
  193.       * screen UNLESS you move the cursor.
  194.       * In dBASE IV 1.1, you do not need to do this.
  195.       * **********************************************************
  196.       IF db1_0 .AND. recnum # RECNO()
  197.          CALL keybd WITH CHR(5) + CHR(trapkey)    && UP/trapkey
  198.          ON KEY LABEL home DO keyhand
  199.       ELSE
  200.          ON KEY DO keyhand
  201.       ENDIF
  202.    ELSE
  203.       *** No Match
  204.       ? CHR(7)        && Beep
  205.       GOTO recnum
  206.       ON KEY DO keyhand
  207.    ENDIF
  208. ENDCASE
  209. RETURN
  210.  
  211. *!*********************************************************************
  212. *!
  213. *!      Procedure: KEYDISP
  214. *!
  215. *!      Called by: KEYHAND        (procedure in BROWDEMO.PRG)
  216. *!
  217. *!*********************************************************************
  218. PROCEDURE keydisp
  219. PARAMETER dispstr
  220. ****************************************
  221. * Display the current input string
  222. ****************************************
  223. ACTIVATE WINDOW inwin
  224. CLEAR
  225. ? dispstr
  226. ACTIVATE WINDOW browwin
  227. RETURN
  228. *: EOF: BROWDEMO.PRG
  229.